<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="__PUBLIC__/admin/sncss/css/style.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/admin/sncss/css/combo.select.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript" src="__PUBLIC__/admin/datepicker/WdatePicker.js"></script>
<script type="text/javascript">
//时间选择
function selecttime(flag){
	if(flag==1){
		var endTime = $("#countTimeend").val();
		if(endTime != ""){
			WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:endTime});
		}else{
			WdatePicker({dateFmt:'yyyy-MM-dd'});
		}
	}else{
		var startTime = $("#countTimestart").val();
		if(startTime != ""){
			WdatePicker({dateFmt:'yyyy-MM-dd',minDate:startTime});
		}else{
			WdatePicker({dateFmt:'yyyy-MM-dd'});
		}
	}
}
</script>
</head>

<body>

	<div class="place">
	<span>位置：</span>
	<ul class="placeul">
	<li><a>首页</a></li>
	<li><a>自媒体管理</a></li>
	<li><a>创建专辑</a></li>
	<li><a href="{:U('/Home/Media/special_list',array('mmid'=>$mmid))}">返回</a></li>
	</ul>
	</div>

	<div class="formbody">

	<div class="formtitle"><span>创建专辑</span></div>
		<form id="form1" name="form1" method="post" action="{:U('/Home/Media/add_special')}" onsubmit="return form1_submit();">
	<ul class="forminfo">
	<input name="mmid"  type="hidden" value="{$mmid}" />
	<li><label>名称</label><input name="specialname" id="specialname" type="text" class="dfinput" value="" /><i></i></li>
	<li><label>简介</label><textarea name="specialmessage" id="specialmessage" type="text" class="textinput"></textarea><i></i></li>
	<li>
		<div style="width: 86px;line-height: 34px;display: block;float: left;">头像</div>
		<div id="container_pic" style="float: left;">
			<a class="btn" id="pickfiles_pic" href="#" style="display: block; text-align: center;line-height: 36px;" ><span id="updata_more_audio_finish_pic">选择文件</span></a>
			<input id="media_pic" type="hidden" value="" name="media_pic" />
		</div>
		<img src="" onerror="this.src=''" width='200' id='ad-img'/>
		<div style="clear: both;"></div>
	</li>
	<li><br><br><label>&nbsp;</label><input name="" type="submit" class="btn" value="确认"/></li>
	</ul>
		</form>

	</div>


</body>
<script src="__PUBLIC__/js/jquery1.8.3.js"></script>
<script src="__PUBLIC__/layer/layer.js"></script>
<script type="text/javascript" src='__PUBLIC__/admin/Js/plupload.full.min.js'></script>
<!-- qiniu.js依赖于Plupload，所以Plupload要在qiniu.js之前引用 -->
<script type="text/javascript" src="__PUBLIC__/admin/Js/qiniu.js"></script>
<script type="text/javascript">
	//===========================================================================================================================================
var ADMIN_URL = "<?php echo "http://".ADMIN_URL;?>"
	Qiniu.uploader({
			runtimes: 'html5,flash,html4',
			browse_button: 'pickfiles_pic',
			// HTML中重要的div的ID
			container: 'container_pic',
			drop_element: 'container_pic',
			max_file_size: '100mb',
			dragdrop: true,
			chunk_size: '100mb',
			uptoken_url:ADMIN_URL+'home/Common/uptoken_image',
			domain: 'http://idv0c0m.qiniudns.com',
			get_new_uptoken: false,
			auto_start:true,
			log_level: 5,
			unique_names: true,
			save_key: false,
			init: {
				'FilesAdded': function(up, file) {
				},
				'BeforeUpload': function(up, file) {
				},
				'UploadProgress': function(up, file) {
					console.log(file.name, file.percent);
          $('#updata_more_audio_finish_pic').text('正在上传（' + file.percent + '%）');
				},
				'UploadComplete': function(up,file) {
						// console.log("我是七牛",this);
				},
				'FileUploaded': function(up, file, info) {
						// console.log('文件上传完成后！');
          	$('#updata_more_audio_finish_pic').text('上传成功');
						var obj=$.parseJSON(info.response);
						var hash=obj.hash;
						var key=obj.key;
						var persistentId=obj.persistentId;
						$('#media_pic').val(key);
						$("#ad-img").attr('src',"http://image.heardtech.com/"+key);
				},
				'Error': function(up, err, errTip) {
          	$('#updata_more_audio_finish_pic').text('上传失败');
				},
				'Key': function(up, file) {
						// var key = "";
						// key=randomWord(true,1,10)+file.name;
						// return key
				}
			},
			filters : {
				max_file_size : '100mb',
				mime_types: [
					{title : "Image files", extensions : "jpg,gif,png"}, // 限定jpg,gif,png后缀上传
				]
			}
	});
	//随机生成随机数
	function randomWord(randomFlag, min, max){
			var str = "",
					range = min,
					arr = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
			// 随机产生
			if(randomFlag){
					range = Math.round(Math.random() * (max-min)) + min;
			}
			for(var i=0; i<range; i++){
					pos = Math.round(Math.random() * (arr.length-1));
					str += arr[pos];
			}
			return str;
	}
//=====================================================================================================================================
</script>
<script type="text/javascript">

function form1_submit(){

	var specialname= $('#specialname').val();
	if(specialname.length == 0){
		layer.tips('请填写名称', '#specialname');return false;
	}
	var specialimg= $('#specialimg').val();
	if(specialimg.length == 0){
		layer.tips('请上传图片', '#specialimg');return false;
	}
	var specialmessage= $('#specialmessage').val();
	if(specialmessage.length == 0){
		layer.tips('请填写简介', '#specialmessage');return false;
	}
	// alert("submit");return false;

}

</script>

</html>
